﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 时间测试
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            using (var db = new Db("TEST3"))
            {
                SqlConnection conn = db.Database.Connection as SqlConnection;
                using (SqlCommand cmd = new SqlCommand("exec Proc_GetTable", conn))
                {
                    SqlDataAdapter sda = new SqlDataAdapter(cmd);
                    sda.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
            }

            DataTable dt2 = new DataTable();
            dt2.Columns.Add("Id", typeof(int));
            dt2.Columns["Id"].AutoIncrementSeed = 1;
            dt2.Columns["Id"].AutoIncrement = true;

            dt2.Columns.Add("PersonName", typeof(string));
            dt2.Columns.Add("PersonBir", typeof(string));
            dt2.Columns.Add("PersonInput", typeof(string));
            dt2.Columns.Add("TestTime", typeof(string));
            dt2.Columns.Add("Num", typeof(string));

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt2.NewRow();
                dr["PersonName"] = dt.Rows[i][1].ToString();
                dr["PersonBir"] = dt.Rows[i][2].ToString();
                dr["PersonInput"] = dt.Rows[i][3].ToString();
                dr["TestTime"] = dt.Rows[i][4].ToString();
                dr["Num"] = dt.Rows[i][5].ToString();
                dt2.Rows.Add(dr);
            }

            dataGridView1.DataSource = dt2;

        }
    }
}
